<include file="nav:headr"/>
<div class="container">
    <div class="row">
        <div style="height: 30px"></div>
        <div class="col-md-2">
            <include file="tools:tools_sider"/>
        </div>
        <div class="col-md-10">
            <div class="page-header">
                <h4>{$page_title}</h4>
            </div>
            <div class="btn-group" role="group" aria-label="...">
                <a  href="{:U('Configs/index')}" type="button" class="btn btn-default">بارلىق تەڭشەكلەر</a>
                <a href="{:U('Configs/add')}" type="button" class="btn btn-default">يېڭىدىن قوشۇش</a>
            </div>
            <br><br>
            <form action="{:U('Configs/saveadd')}" method="post">
                <table class="table table-bordered">
                    <thead>
                    <tr class="active">
                        <td width="30">ID</td>
                        <td> ئىشلىتىلىش چۈشەندۈرۈلىشى </td>
                        <td> تەڭشەك نامى</td>
                        <td>ھەرقايسى بەتلەدە كۆرۈنىدىغان قىممىتى</td>
                        <td>مەشغۇلات</td>
                    </tr>
                    </thead>
                    <tbody>
                    <foreach name="configs" item="c">
                        <input type="hidden" name="id[]" value="{$c['id']}" />
                        <tr>
                            <td>{$c['id']}</td>
                            <td>{$c['title']}</td>
                            <td style="direction: ltr;font-size: 15px" class="text-center">{$c['name']}</td>
                            <td><input onchange="bianji(this,{$c['id']})" type="text" class="form-control" value="{$c['value']}" name="value[]"></td>
                            <td>
                                <a  href="{:U('Configs/edit',array('id'=>$c['id']))}" class="btn btn-success btn-sm">چوڭ تەھرىرلەش</a>
                                <a  href="javascript:deleteConfig({$c['id']})" class="btn btn-danger btn-sm">ئۆچۈرۈش</a>
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
                <!--<input type="submit" class="btn btn-primary" value="يېڭىلاش">-->
            </form>
        </div>
        <script type="text/javascript">
            //编辑
            function bianji(obj,id) {
                var value=$(obj).val();
                $.ajax({
                    'url':'{:U("Configs/bianji")}',
                    'type':'POST',
                    'dataType':'json',
                    'data':{'value':value,'id':id},
                    success:function (phpRetrnData) {
                        if(phpRetrnData.status){
                            layer.msg(phpRetrnData.message,{'icon':6},function () {
                                window.location=location;
                            })
                        }else {
                            layer.msg(phpRetrnData.message,{'icon':5});
                        }
                    }
                })
            }

            function deleteConfig(id) {
                //询问框
                layer.confirm('راستىنلا ئۆچۈرەمسىز？', {
                    btn: ['ھەئە','ياق'] //按钮
                }, function(){
                    $.ajax({
                        'url':"{:U('Configs/deleteConfig')}",
                        'type':'POST',
                        'dataType':'json',
                        'data':{'id':id},
                        success:function (phpRetrnData) {
                            if(phpRetrnData.status){
                                layer.msg(phpRetrnData.message,{'icon':6},function () {
                                    window.location=location;
                                })
                            }else {
                                layer.msg(phpRetrnData.message,{'icon':5});
                            }
                        }
                    });
                })
            }
        </script>
<include file="nav:footer" />